<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="​        原文地址：https:&#x2F;&#x2F;zhuanlan.zhihu.com&#x2F;p&#x2F;454677252 ​        首先是获取LVGL源码，目前源码只在GitHub仓库中管理，可通过搜索LVGL官网转至git仓库或点击此仓库地址进行下载https:&#x2F;&#x2F;github.com&#x2F;lvgl. ​        下面将进行所需硬件配套驱动程序的准备。因为所要移植的是LVGL，所以显示屏驱动的必须的，">
<meta property="og:type" content="article">
<meta property="og:title" content="原子探索者开发板移植lvgl">
<meta property="og:url" content="http://example.com/2023/12/02/%E5%8E%9F%E5%AD%90%E6%8E%A2%E7%B4%A2%E8%80%85%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A7%BB%E6%A4%8Dlvgl/index.html">
<meta property="og:site_name" content="学无止境">
<meta property="og:description" content="​        原文地址：https:&#x2F;&#x2F;zhuanlan.zhihu.com&#x2F;p&#x2F;454677252 ​        首先是获取LVGL源码，目前源码只在GitHub仓库中管理，可通过搜索LVGL官网转至git仓库或点击此仓库地址进行下载https:&#x2F;&#x2F;github.com&#x2F;lvgl. ​        下面将进行所需硬件配套驱动程序的准备。因为所要移植的是LVGL，所以显示屏驱动的必须的，">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312022223031.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312022225917.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030839263.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030921077.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030926842.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030928222.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030935231.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030951770.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030956605.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031001695.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031011245.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031012667.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031012291.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031013709.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031013707.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031014266.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031014019.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031026788.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031035344.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031037250.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031145120.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031608793.jpg">
<meta property="article:published_time" content="2023-12-02T14:02:12.000Z">
<meta property="article:modified_time" content="2023-12-02T14:02:12.000Z">
<meta property="article:author" content="xudonglei">
<meta property="article:tag" content="stm32">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312022223031.png">

<link rel="canonical" href="http://example.com/2023/12/02/%E5%8E%9F%E5%AD%90%E6%8E%A2%E7%B4%A2%E8%80%85%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A7%BB%E6%A4%8Dlvgl/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>原子探索者开发板移植lvgl | 学无止境</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">学无止境</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Do not bb, show me the example</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/02/%E5%8E%9F%E5%AD%90%E6%8E%A2%E7%B4%A2%E8%80%85%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A7%BB%E6%A4%8Dlvgl/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          原子探索者开发板移植lvgl
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-02 22:02:12" itemprop="dateCreated datePublished" datetime="2023-12-02T22:02:12+08:00">2023-12-02</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/12/02/%E5%8E%9F%E5%AD%90%E6%8E%A2%E7%B4%A2%E8%80%85%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A7%BB%E6%A4%8Dlvgl/" class="post-meta-item leancloud_visitors" data-flag-title="原子探索者开发板移植lvgl" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/02/%E5%8E%9F%E5%AD%90%E6%8E%A2%E7%B4%A2%E8%80%85%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A7%BB%E6%A4%8Dlvgl/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/02/%E5%8E%9F%E5%AD%90%E6%8E%A2%E7%B4%A2%E8%80%85%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A7%BB%E6%A4%8Dlvgl/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>​        原文地址：<a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/454677252">https://zhuanlan.zhihu.com/p/454677252</a></p>
<p>​        首先是获取LVGL源码，目前源码只在GitHub仓库中管理，可通过搜索LVGL官网转至git仓库或点击此仓库地址进行下载<a target="_blank" rel="noopener" href="https://github.com/lvgl">https://github.com/lvgl</a>.</p>
<p>​        下面将进行所需硬件配套驱动程序的准备。因为所要移植的是LVGL，所以显示屏驱动的必须的，此外还需移植显示屏的触摸驱动，以便进行触控调试。方便起见，这里直接在原子触摸屏驱动实验例程上修改。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312022223031.png"></p>
<p>​        复制出后将文件更名为LVGL，并打开目录..\LVGL\USER将下图的两个文件也进行更名；</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312022225917.png" style="zoom:57%;">

<p>​        打开工程对工程名和目标文件输出目录名称做修改：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030839263.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030921077.png" style="zoom:50%;">

<p>​        编译工程，然后对工程进行调整，首先删除main.c中多余的内容，只保留下图所示的内容；</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030926842.png" style="zoom:67%;">

<p>​        修改堆和栈大小，LVGL要求栈至少为2K,这里我们适当给大一点，STM32F4足够提供这个大小</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030928222.png" style="zoom:60%;">

<p>​        使能C99编译器，否则工程无法编译通过.截止目前准备工作才算完成，简单编译一下原工程，确保无错误后咱们进行LVGL的移植工作。</p>
<p>​        首先在工程目录下添加两个文件夹LV以及GUI_APP,这两个文件夹分别用于存放LVGL的源码以及后期用户的应用代码：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030935231.png" style="zoom:60%;">

<p>​        打开之前下载并解压好的LVGL源码,然后将下图红框中的三个文件复制到上一步创建的LV文件夹中，其中src为LVGL的各个组件源码，lv_conf_template.h为LVGL的配置文件，使用时用户可以通过此文件更改参数选项，lvgl.h为LVGL的各个头文件调用的文件。将这些文件拷贝到LV文件夹后，如下图所示:</p>
 <img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030951770.png" style="zoom:67%;">

<p>将lv_conf_template.h重命名为lv_conf.h（这只是为了使用习惯的方便）。lv_conf.h默认是不使能的，所以需要打开lv_conf.h中的编译使能，将if 0 改为 if 1：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312030956605.png" style="zoom:50%;">

<p>​        打开Keil项目工程，然后参照LV\src目录，在工程目录下创建目录以及GUI_APP子条目，没有创建LV_GPU原因是我们所使用的开发板并未使用到GPU功能：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031001695.png" style="zoom:67%;">

<p>​        参照LV\src目录将对应的.c文件添加到上一步创建的条目中，这一步需要一定的耐心，这部分将会把所有的添加过程一 一列出：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031011245.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031012667.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031012291.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031013709.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031013707.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031014266.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031014019.png" style="zoom:67%;">

<p>​        上一步完成了.c文件的的导入，下面将对.h文件进行导入，添加完成后的目录下图所示。这也是个细致活：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031026788.png" style="zoom:67%;">

<p>添加完成后点击编译工程，没有错误。</p>
<p>​        这里还没完，不要着急，下面将移植显示驱动接口以及触摸驱动接口。打开gihub 下载解压后文件目录lvgl-master\examples\porting ，将会看到下图所示的的六个文件，其中lv_port_disp_template.c lv_port_disp_template.h文件为LVGL提供给用户实现的显示驱动接口；lv_port_indev_template.c lv_port_indev_template.h文件为LVGL提供给用户实现的触摸驱动接口；lv_port_fs_template.c lv_port_fs_template.h文件为LVGL提供给用户实现的文件系统接口。这里我们需要将lv_port_disp_template.c lv_port_disp_template.h lv_port_indev_template.c lv_port_indev_template.h四个文件复制到Keil工程的LV文件夹中并将其中的_template字段删除，如下图所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031035344.png" style="zoom:67%;">

<p>​        Keil 工程中增加LV_PORT的目录条目，如下所示，添加lv_port_indev.c lv_port_disp.c 文件：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031037250.png" style="zoom:67%;">

<p>​        修改lv_port_indev.h lv_port_disp.h的内容，因为二者默认是不启动编译的，修改内容改成#if 1。</p>
<p>​        修改lv_port_indev.c lv_port_disp.c文件，将lv_port_disp.c中的内容换为以下内容:</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * @file lv_port_disp_templ.c</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*Copy this file as &quot;lv_port_disp.c&quot; and set this value to &quot;1&quot; to enable content*/</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 1</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*********************</span></span><br><span class="line"><span class="comment"> *      INCLUDES</span></span><br><span class="line"><span class="comment"> *********************/</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lv_port_disp.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;../../lvgl.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lcd.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*********************</span></span><br><span class="line"><span class="comment"> *      DEFINES</span></span><br><span class="line"><span class="comment"> *********************/</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> MY_DISP_HOR_RES</span></span><br><span class="line">    <span class="meta">#<span class="meta-keyword">warning</span> Please <span class="meta-keyword">define</span> or replace the macro MY_DISP_HOR_RES with the actual screen width, default value 320 is used for now.</span></span><br><span class="line">    <span class="meta">#<span class="meta-keyword">define</span> MY_DISP_HOR_RES    320</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> MY_DISP_VER_RES</span></span><br><span class="line">    <span class="meta">#<span class="meta-keyword">warning</span> Please <span class="meta-keyword">define</span> or replace the macro MY_DISP_HOR_RES with the actual screen height, default value 240 is used for now.</span></span><br><span class="line">    <span class="meta">#<span class="meta-keyword">define</span> MY_DISP_VER_RES    240</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *      TYPEDEFS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *  STATIC PROTOTYPES</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">disp_init</span><span class="params">(<span class="keyword">void</span>)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">disp_flush</span><span class="params">(<span class="keyword">lv_disp_drv_t</span> * disp_drv, <span class="keyword">const</span> <span class="keyword">lv_area_t</span> * area, <span class="keyword">lv_color_t</span> * color_p)</span></span>;</span><br><span class="line"><span class="comment">//static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,</span></span><br><span class="line"><span class="comment">//        const lv_area_t * fill_area, lv_color_t color);</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *  STATIC VARIABLES</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *      MACROS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *   GLOBAL FUNCTIONS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">lv_port_disp_init</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">/*-------------------------</span></span><br><span class="line"><span class="comment">     * Initialize your display</span></span><br><span class="line"><span class="comment">     * -----------------------*/</span></span><br><span class="line">    disp_init();</span><br><span class="line"></span><br><span class="line">    <span class="comment">/*-----------------------------</span></span><br><span class="line"><span class="comment">     * Create a buffer for drawing</span></span><br><span class="line"><span class="comment">     *----------------------------*/</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * LVGL requires a buffer where it internally draws the widgets.</span></span><br><span class="line"><span class="comment">     * Later this buffer will passed to your display driver&#x27;s `flush_cb` to copy its content to your display.</span></span><br><span class="line"><span class="comment">     * The buffer has to be greater than 1 display row</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * There are 3 buffering configurations:</span></span><br><span class="line"><span class="comment">     * 1. Create ONE buffer:</span></span><br><span class="line"><span class="comment">     *      LVGL will draw the display&#x27;s content here and writes it to your display</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * 2. Create TWO buffer:</span></span><br><span class="line"><span class="comment">     *      LVGL will draw the display&#x27;s content to a buffer and writes it your display.</span></span><br><span class="line"><span class="comment">     *      You should use DMA to write the buffer&#x27;s content to the display.</span></span><br><span class="line"><span class="comment">     *      It will enable LVGL to draw the next part of the screen to the other buffer while</span></span><br><span class="line"><span class="comment">     *      the data is being sent form the first buffer. It makes rendering and flushing parallel.</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * 3. Double buffering</span></span><br><span class="line"><span class="comment">     *      Set 2 screens sized buffers and set disp_drv.full_refresh = 1.</span></span><br><span class="line"><span class="comment">     *      This way LVGL will always provide the whole rendered screen in `flush_cb`</span></span><br><span class="line"><span class="comment">     *      and you only need to change the frame buffer&#x27;s address.</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/* Example for 1) */</span></span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">lv_disp_draw_buf_t</span> draw_buf_dsc_1;</span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">lv_color_t</span> buf_1[MY_DISP_HOR_RES * <span class="number">10</span>];                          <span class="comment">/*A buffer for 10 rows*/</span></span><br><span class="line">    lv_disp_draw_buf_init(&amp;draw_buf_dsc_1, buf_1, <span class="literal">NULL</span>, MY_DISP_HOR_RES * <span class="number">10</span>);   <span class="comment">/*Initialize the display buffer*/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//    /* Example for 2) */</span></span><br><span class="line"><span class="comment">//    static lv_disp_draw_buf_t draw_buf_dsc_2;</span></span><br><span class="line"><span class="comment">//    static lv_color_t buf_2_1[MY_DISP_HOR_RES * 10];                        /*A buffer for 10 rows*/</span></span><br><span class="line"><span class="comment">//    static lv_color_t buf_2_2[MY_DISP_HOR_RES * 10];                        /*An other buffer for 10 rows*/</span></span><br><span class="line"><span class="comment">//    lv_disp_draw_buf_init(&amp;draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 10);   /*Initialize the display buffer*/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//    /* Example for 3) also set disp_drv.full_refresh = 1 below*/</span></span><br><span class="line"><span class="comment">//    static lv_disp_draw_buf_t draw_buf_dsc_3;</span></span><br><span class="line"><span class="comment">//    static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES];            /*A screen sized buffer*/</span></span><br><span class="line"><span class="comment">//    static lv_color_t buf_3_2[MY_DISP_HOR_RES * MY_DISP_VER_RES];            /*Another screen sized buffer*/</span></span><br><span class="line"><span class="comment">//    lv_disp_draw_buf_init(&amp;draw_buf_dsc_3, buf_3_1, buf_3_2,</span></span><br><span class="line"><span class="comment">//                          MY_DISP_VER_RES * LV_VER_RES_MAX);   /*Initialize the display buffer*/</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/*-----------------------------------</span></span><br><span class="line"><span class="comment">     * Register the display in LVGL</span></span><br><span class="line"><span class="comment">     *----------------------------------*/</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">lv_disp_drv_t</span> disp_drv;                         <span class="comment">/*Descriptor of a display driver*/</span></span><br><span class="line">    lv_disp_drv_init(&amp;disp_drv);                    <span class="comment">/*Basic initialization*/</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Set up the functions to access to your display*/</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Set the resolution of the display*/</span></span><br><span class="line">    disp_drv.hor_res = lcddev.width;</span><br><span class="line">    disp_drv.ver_res = lcddev.height;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Used to copy the buffer&#x27;s content to the display*/</span></span><br><span class="line">    disp_drv.flush_cb = disp_flush;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Set a display buffer*/</span></span><br><span class="line">    disp_drv.draw_buf = &amp;draw_buf_dsc_1;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Required for Example 3)*/</span></span><br><span class="line">    <span class="comment">//disp_drv.full_refresh = 1;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/* Fill a memory array with a color if you have GPU.</span></span><br><span class="line"><span class="comment">     * Note that, in lv_conf.h you can enable GPUs that has built-in support in LVGL.</span></span><br><span class="line"><span class="comment">     * But if you have a different GPU you can use with this callback.*/</span></span><br><span class="line">    <span class="comment">//disp_drv.gpu_fill_cb = gpu_fill;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Finally register the driver*/</span></span><br><span class="line">    lv_disp_drv_register(&amp;disp_drv);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *   STATIC FUNCTIONS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*Initialize your display and the required peripherals.*/</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">disp_init</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">/*You code here*/</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">volatile</span> <span class="keyword">bool</span> disp_flush_enabled = <span class="literal">true</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">/* Enable updating the screen (the flushing process) when disp_flush() is called by LVGL</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">disp_enable_update</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    disp_flush_enabled = <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/* Disable updating the screen (the flushing process) when disp_flush() is called by LVGL</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">disp_disable_update</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    disp_flush_enabled = <span class="literal">false</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/*Flush the content of the internal buffer the specific area on the display</span></span><br><span class="line"><span class="comment"> *You can use DMA or any hardware acceleration to do this operation in the background but</span></span><br><span class="line"><span class="comment"> *&#x27;lv_disp_flush_ready()&#x27; has to be called when finished.*/</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">disp_flush</span><span class="params">(<span class="keyword">lv_disp_drv_t</span> * disp_drv, <span class="keyword">const</span> <span class="keyword">lv_area_t</span> * area, <span class="keyword">lv_color_t</span> * color_p)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line"><span class="comment">//    if(disp_flush_enabled) &#123;</span></span><br><span class="line"><span class="comment">//        /*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//        int32_t x;</span></span><br><span class="line"><span class="comment">//        int32_t y;</span></span><br><span class="line"><span class="comment">//        for(y = area-&gt;y1; y &lt;= area-&gt;y2; y++) &#123;</span></span><br><span class="line"><span class="comment">//            for(x = area-&gt;x1; x &lt;= area-&gt;x2; x++) &#123;</span></span><br><span class="line"><span class="comment">//                /*Put a pixel to the display. For example:*/</span></span><br><span class="line"><span class="comment">//                /*put_px(x, y, *color_p)*/</span></span><br><span class="line"><span class="comment">//                color_p++;</span></span><br><span class="line"><span class="comment">//            &#125;</span></span><br><span class="line"><span class="comment">//        &#125;</span></span><br><span class="line"><span class="comment">//    &#125;</span></span><br><span class="line">		LCD_Color_Fill(area-&gt;x1,area-&gt;y1,area-&gt;x2,area-&gt;y2,(u16*)color_p);</span><br><span class="line"></span><br><span class="line">    <span class="comment">/*IMPORTANT!!!</span></span><br><span class="line"><span class="comment">     *Inform the graphics library that you are ready with the flushing*/</span></span><br><span class="line">    lv_disp_flush_ready(disp_drv);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/*OPTIONAL: GPU INTERFACE*/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color*/</span></span><br><span class="line"><span class="comment">//static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,</span></span><br><span class="line"><span class="comment">//                    const lv_area_t * fill_area, lv_color_t color)</span></span><br><span class="line"><span class="comment">//&#123;</span></span><br><span class="line"><span class="comment">//    /*It&#x27;s an example code which should be done by your GPU*/</span></span><br><span class="line"><span class="comment">//    int32_t x, y;</span></span><br><span class="line"><span class="comment">//    dest_buf += dest_width * fill_area-&gt;y1; /*Go to the first line*/</span></span><br><span class="line"><span class="comment">//</span></span><br><span class="line"><span class="comment">//    for(y = fill_area-&gt;y1; y &lt;= fill_area-&gt;y2; y++) &#123;</span></span><br><span class="line"><span class="comment">//        for(x = fill_area-&gt;x1; x &lt;= fill_area-&gt;x2; x++) &#123;</span></span><br><span class="line"><span class="comment">//            dest_buf[x] = color;</span></span><br><span class="line"><span class="comment">//        &#125;</span></span><br><span class="line"><span class="comment">//        dest_buf+=dest_width;    /*Go to the next line*/</span></span><br><span class="line"><span class="comment">//    &#125;</span></span><br><span class="line"><span class="comment">//&#125;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">else</span> <span class="comment">/*Enable this file at the top*/</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*This dummy typedef exists purely to silence -Wpedantic.*/</span></span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">int</span> keep_pedantic_happy;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br></pre></td></tr></table></figure>
<p>将lv_port_indev.c中的内容换为以下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * @file lv_port_indev_templ.c</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"> <span class="comment">/*Copy this file as &quot;lv_port_indev.c&quot; and set this value to &quot;1&quot; to enable content*/</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 1</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*********************</span></span><br><span class="line"><span class="comment"> *      INCLUDES</span></span><br><span class="line"><span class="comment"> *********************/</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lv_port_indev.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;../../lvgl.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;touch.h&quot;</span></span></span><br><span class="line"><span class="comment">/*********************</span></span><br><span class="line"><span class="comment"> *      DEFINES</span></span><br><span class="line"><span class="comment"> *********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *      TYPEDEFS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *  STATIC PROTOTYPES</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">touchpad_read</span><span class="params">(<span class="keyword">lv_indev_drv_t</span> * indev_drv, <span class="keyword">lv_indev_data_t</span> * data)</span></span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">lv_indev_t</span> * indev_touchpad;</span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *      MACROS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**********************</span></span><br><span class="line"><span class="comment"> *   GLOBAL FUNCTIONS</span></span><br><span class="line"><span class="comment"> **********************/</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">lv_port_indev_init</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * Here you will find example implementation of input devices supported by LittelvGL:</span></span><br><span class="line"><span class="comment">     *  - Touchpad</span></span><br><span class="line"><span class="comment">     *  - Mouse (with cursor support)</span></span><br><span class="line"><span class="comment">     *  - Keypad (supports GUI usage only with key)</span></span><br><span class="line"><span class="comment">     *  - Encoder (supports GUI usage only with: left, right, push)</span></span><br><span class="line"><span class="comment">     *  - Button (external buttons to press points on the screen)</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     *  The `..._read()` function are only examples.</span></span><br><span class="line"><span class="comment">     *  You should shape them according to your hardware</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">lv_indev_drv_t</span> indev_drv;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/*------------------</span></span><br><span class="line"><span class="comment">     * Touchpad</span></span><br><span class="line"><span class="comment">     * -----------------*/</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Initialize your touchpad if you have*/</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">/*Register a touchpad input device*/</span></span><br><span class="line">    lv_indev_drv_init(&amp;indev_drv);</span><br><span class="line">    indev_drv.type = LV_INDEV_TYPE_POINTER;</span><br><span class="line">    indev_drv.read_cb = touchpad_read;</span><br><span class="line">    indev_touchpad = lv_indev_drv_register(&amp;indev_drv);</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">/*Will be called by the library to read the touchpad*/</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">touchpad_read</span><span class="params">(<span class="keyword">lv_indev_drv_t</span> * indev_drv, <span class="keyword">lv_indev_data_t</span> * data)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">lv_coord_t</span> last_x = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">lv_coord_t</span> last_y = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span>(tp_dev.sta&amp;TP_PRES_DOWN)<span class="comment">//触摸按下了</span></span><br><span class="line">		&#123;</span><br><span class="line">			last_x = tp_dev.x[<span class="number">0</span>];</span><br><span class="line">			last_y = tp_dev.y[<span class="number">0</span>];</span><br><span class="line">			data-&gt;point.x = last_x;</span><br><span class="line">			data-&gt;point.y = last_y;</span><br><span class="line">			data-&gt;state = LV_INDEV_STATE_PR;</span><br><span class="line">		&#125;<span class="keyword">else</span>&#123;</span><br><span class="line">			data-&gt;point.x = last_x;</span><br><span class="line">			data-&gt;point.y = last_y;</span><br><span class="line">			data-&gt;state = LV_INDEV_STATE_REL;</span><br><span class="line">		&#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">else</span> <span class="comment">/*Enable this file at the top*/</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*This dummy typedef exists purely to silence -Wpedantic.*/</span></span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">int</span> keep_pedantic_happy;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br></pre></td></tr></table></figure>
<p>main.c文件编写：<br>添加头文件<br>#include “lvgl.h”</p>
<p>#include “lv_port_disp.h”</p>
<p>#include “lv_port_indev.h”</p>
<p>初始化LVGL、显示接口以及触摸接口初始化一定要的LVGL初始化之后:</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031145120.png" style="zoom:67%;">

<p>​        编译工程无措无错误后为LVGL添加始终节拍，这里使用STM32的定时器3来提供时钟节拍，在工程中添加定时器配置的代码：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;timer.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lvgl.h&quot;</span></span></span><br><span class="line"><span class="comment">//////////////////////////////////////////////////////////////////////////////////	 </span></span><br><span class="line"><span class="comment">//本程序只供学习使用，未经作者许可，不得用于其它任何用途</span></span><br><span class="line"><span class="comment">//ALIENTEK STM32F407开发板</span></span><br><span class="line"><span class="comment">//定时器 驱动代码	   </span></span><br><span class="line"><span class="comment">//正点原子@ALIENTEK</span></span><br><span class="line"><span class="comment">//技术论坛:www.openedv.com</span></span><br><span class="line"><span class="comment">//创建日期:2014/5/4</span></span><br><span class="line"><span class="comment">//版本：V1.0</span></span><br><span class="line"><span class="comment">//版权所有，盗版必究。</span></span><br><span class="line"><span class="comment">//Copyright(C) 广州市星翼电子科技有限公司 2014-2024</span></span><br><span class="line"><span class="comment">//All rights reserved									  </span></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////// 	 </span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">//通用定时器3中断初始化</span></span><br><span class="line"><span class="comment">//arr：自动重装值。</span></span><br><span class="line"><span class="comment">//psc：时钟预分频数</span></span><br><span class="line"><span class="comment">//定时器溢出时间计算方法:Tout=((arr+1)*(psc+1))/Ft us.</span></span><br><span class="line"><span class="comment">//Ft=定时器工作频率,单位:Mhz</span></span><br><span class="line"><span class="comment">//这里使用的是定时器3!</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">TIM3_Int_Init</span><span class="params">(u16 arr,u16 psc)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;</span><br><span class="line">	NVIC_InitTypeDef NVIC_InitStructure;</span><br><span class="line">	</span><br><span class="line">	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE);  <span class="comment">///使能TIM3时钟</span></span><br><span class="line">	</span><br><span class="line">  TIM_TimeBaseInitStructure.TIM_Period = arr; 	<span class="comment">//自动重装载值</span></span><br><span class="line">	TIM_TimeBaseInitStructure.TIM_Prescaler=psc;  <span class="comment">//定时器分频</span></span><br><span class="line">	TIM_TimeBaseInitStructure.TIM_CounterMode=TIM_CounterMode_Up; <span class="comment">//向上计数模式</span></span><br><span class="line">	TIM_TimeBaseInitStructure.TIM_ClockDivision=TIM_CKD_DIV1; </span><br><span class="line">	</span><br><span class="line">	TIM_TimeBaseInit(TIM3,&amp;TIM_TimeBaseInitStructure);<span class="comment">//初始化TIM3</span></span><br><span class="line">	</span><br><span class="line">	TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE); <span class="comment">//允许定时器3更新中断</span></span><br><span class="line">	TIM_Cmd(TIM3,ENABLE); <span class="comment">//使能定时器3</span></span><br><span class="line">	</span><br><span class="line">	NVIC_InitStructure.NVIC_IRQChannel=TIM3_IRQn; <span class="comment">//定时器3中断</span></span><br><span class="line">	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=<span class="number">0x01</span>; <span class="comment">//抢占优先级1</span></span><br><span class="line">	NVIC_InitStructure.NVIC_IRQChannelSubPriority=<span class="number">0x03</span>; <span class="comment">//子优先级3</span></span><br><span class="line">	NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;</span><br><span class="line">	NVIC_Init(&amp;NVIC_InitStructure);</span><br><span class="line">	</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//定时器3中断服务程序</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">TIM3_IRQHandler</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123; 		    		  			    </span><br><span class="line">	<span class="keyword">if</span>(TIM3-&gt;SR&amp;TIM_IT_Update)<span class="comment">//溢出中断</span></span><br><span class="line">	&#123;</span><br><span class="line">		lv_tick_inc(<span class="number">1</span>);<span class="comment">//lvgl的1ms心跳</span></span><br><span class="line">	&#125;				   </span><br><span class="line">	TIM3-&gt;SR = (<span class="keyword">uint16_t</span>)~TIM_IT_Update;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>main.c中添加一下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;sys.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;delay.h&quot;</span>  </span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;usart.h&quot;</span>   </span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;led.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lcd.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;key.h&quot;</span>  </span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;touch.h&quot;</span> </span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;timer.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lvgl.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lv_port_disp.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;lv_port_indev.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">event_handler</span><span class="params">(<span class="keyword">lv_event_t</span> * e)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">lv_event_code_t</span> code = lv_event_get_code(e);</span><br><span class="line">    <span class="keyword">lv_obj_t</span> * obj = lv_event_get_target(e);</span><br><span class="line">    <span class="keyword">if</span>(code == LV_EVENT_VALUE_CHANGED) &#123;</span><br><span class="line">        <span class="keyword">char</span> buf[<span class="number">32</span>];</span><br><span class="line">        lv_roller_get_selected_str(obj, buf, <span class="keyword">sizeof</span>(buf));</span><br><span class="line">        LV_LOG_USER(<span class="string">&quot;Selected month: %s\n&quot;</span>, buf);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * An infinite roller with the name of the months</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">lv_example_roller_1</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">lv_obj_t</span> *roller1 = lv_roller_create(lv_scr_act());</span><br><span class="line">    lv_roller_set_options(roller1,</span><br><span class="line">                        <span class="string">&quot;January\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;February\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;March\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;April\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;May\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;June\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;July\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;August\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;September\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;October\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;November\n&quot;</span></span><br><span class="line">                        <span class="string">&quot;December&quot;</span>,</span><br><span class="line">                        LV_ROLLER_MODE_INFINITE);</span><br><span class="line"></span><br><span class="line">    lv_roller_set_visible_row_count(roller1, <span class="number">4</span>);</span><br><span class="line">    lv_obj_center(roller1);</span><br><span class="line">    lv_obj_add_event_cb(roller1, event_handler, LV_EVENT_ALL, <span class="literal">NULL</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123; </span><br><span class="line"></span><br><span class="line">	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);<span class="comment">//设置系统中断优先级分组2</span></span><br><span class="line">	delay_init(<span class="number">168</span>);  <span class="comment">//初始化延时函数</span></span><br><span class="line">	uart_init(<span class="number">115200</span>);		<span class="comment">//初始化串口波特率为115200</span></span><br><span class="line">	</span><br><span class="line">	LED_Init();					<span class="comment">//初始化LED </span></span><br><span class="line"> 	LCD_Init();					<span class="comment">//LCD初始化 </span></span><br><span class="line">	KEY_Init(); 				<span class="comment">//按键初始化  </span></span><br><span class="line">    TIM3_Int_Init(<span class="number">999</span>,<span class="number">83</span>);</span><br><span class="line">	tp_dev.init();				<span class="comment">//触摸屏初始化</span></span><br><span class="line">    </span><br><span class="line">    lv_init();						<span class="comment">//lvgl系统初始化</span></span><br><span class="line">	lv_port_disp_init();	<span class="comment">//lvgl显示接口初始化,放在lv_init()的后面</span></span><br><span class="line">	lv_port_indev_init();	<span class="comment">//lvgl输入接口初始化,放在lv_init()的后面</span></span><br><span class="line">	</span><br><span class="line">    lv_example_roller_1();</span><br><span class="line">    <span class="keyword">while</span>(<span class="number">1</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        tp_dev.scan(<span class="number">0</span>);</span><br><span class="line">		lv_task_handler();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>编译并烧录到开发板中显示效果如图所示，至此LVGL移植成功：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312031608793.jpg" style="zoom:60%;">

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/stm32/" rel="tag"># stm32</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2023/12/01/%E4%BD%BF%E7%94%A8wx%E4%B8%AD%E7%9A%84Panel/" rel="prev" title="使用wx中的Panel">
      <i class="fa fa-chevron-left"></i> 使用wx中的Panel
    </a></div>
      <div class="post-nav-item">
    <a href="/2023/12/06/%E7%90%86%E8%A7%A3%E8%BF%90%E6%94%BE%E7%9A%84%E8%99%9A%E7%9F%AD%E5%92%8C%E8%99%9A%E6%96%AD/" rel="next" title="理解运放的虚短和虚断">
      理解运放的虚短和虚断 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">xudonglei</p>
  <div class="site-description" itemprop="description">搬砖 嵌入式</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">283</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">67</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">xudonglei</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'BT0Qw9HcTpPv1a6cT1iDBXKz-gzGzoHsz',
      appKey     : 'LMCMh8v02JTMFAwKNRcgoizI',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
